/*
 
    Copyright (c) 2010 Ralf Westphal <info@ralfw.de>
     
    This file is part of NZMQ, nzmq.codeplex.com
     
    NZMQ is free software; you can redistribute it and/or modify it under
    the terms of the Lesser GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
     
    NZMQ is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    Lesser GNU General Public License for more details.
     
    You should have received a copy of the Lesser GNU General Public License
    along with this program. If not, see <http://www.gnu.org/licenses/>.

*/
using nzmq.raw;

namespace nzmq
{
    public class NzmqServiceSocket : NzmqBaseSocket
    {
        internal NzmqServiceSocket(LibzmqSocket rawSocket) : base(rawSocket)
        {}


        public void Reply(object message) { Reply(message, false); }
        public void Reply(object message, bool isMultipart)
        {
            base.Send(message, isMultipart);
        }


        public T Receive<T>()
        {
            return (T)base.Receive();
        }


        public bool TryReceive<T>(out T message, int timeoutMilliseconds)
        {
            if (NzmqCoordination.WaitAll(timeoutMilliseconds, this))
            {
                message = (T)base.Receive();
                return true;
            }

            message = default(T);
            return false;
        }
    }
}